﻿
using System;
using System.Collections;
using UnityEngine;
using UniRx;
using System.Collections.Generic;

public class Testsss : MonoBehaviour
{

    [SerializeField]
    private List<Vector2> moveList=new List<Vector2>(100000);
    void Start()
    {
        Observable.EveryUpdate()
        .Where(_ => Input.GetMouseButtonDown(0))
        .Subscribe(_ =>
        {
            // Observable.FromCoroutine<float>(o => MyLoad(o)).Subscribe(x =>
            // {
            //     Debug.Log(x + "from coroutine value");
            // });

            Observable.FromCoroutineValue<Vector2>(MovePositionCoroutine)
            .Subscribe(x => Debug.Log(x));

        });

    }

    IEnumerator MovePositionCoroutine()
    {
        foreach (var item in moveList)
        {
            yield return null;
            yield return item;
        }
    }
    IEnumerator MyLoad(IObserver<float> observer)
    {
        var count = 0;
        while (true)
        {
            yield return null;
            observer.OnNext(count);
            count++;
        }
        observer.OnCompleted();
    }
}

